package com.liming;

import java.util.*;

public class CollectionsDemo {
    public static void main(String[] args) {
        // 创建一个集合
        List<String> list = new LinkedList<>();
        Collections.addAll(list,"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
        list.forEach(System.out::println);
        System.out.println("------------------------");
        // 打乱集合中的元素
        Collections.shuffle(list);
        list.forEach(System.out::println);
        System.out.println("------------------------");
        test01();
    }
    public static void test01(){
        // 创建一个集合
        List<Integer> list1 = new LinkedList<>();
        Collections.addAll(list1,1,2,3,4,5,6,7,8,9,10);
        Collections.sort(list1);
        list1.forEach(System.out::println);
        Collections.sort(list1, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        System.out.println("------------------------");
        list1.forEach(System.out::println);
        List<Student> list2 = new LinkedList<>();
        list2.add(new Student("肖博文",20));
        list2.add(new Student("萧炎",21));
        list2.add(new Student("唐三",22));
        list2.add(new Student("小舞",23));
        list2.add(new Student("荒天帝",24));
        Collections.sort(list2);
        list2.forEach(System.out::println);

        List<Integer> sychronizedList = Collections.synchronizedList(list1);
        }

}
